home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-06-10 | 13.3 KB | 590 lines | [TEXT/MPS ] |
-
- ;;;
- ;;; MIDI.a
- ;;;
- ;;; This file contains the assembly-language interface for the MIDI Manager.
- ;;;
- ;;; Author: John Worthington, Don Marsh, Mark Lentczner
- ;;; Copyright © 1988, Apple Computer, Inc.
- ;;; All Rights Reserved
- ;;;
- ;;; Version 2.0a1
-
-
-
-
- ;;; ________________________________________________________________________________
- ;;;
- ;;; Constants:
- ;;;
-
- midiToolNum EQU 4 ; tool number of MIDI Mgr for SndDispVersion call.
- midiMaxNameLen EQU 31 ; maximum number of characters in port and client names
-
-
- ; Time formats
-
- midiFormatMSec EQU 0 ; milliseconds
- midiFormatBeats EQU 1 ; beats
- midiFormat24fpsBit EQU 2 ; 24 frames/sec.
- midiFormat25fpsBit EQU 3 ; 25 frames/sec.
- midiFormat30fpsDBit EQU 4 ; 30 frames/sec. drop-frame
- midiFormat30fpsBit EQU 5 ; 30 frames/sec.
- midiFormat24fpsQF EQU 6 ; 24 frames/sec. longInt format
- midiFormat25fpsQF EQU 7 ; 25 frames/sec. longInt format
- midiFormat30fpsDQF EQU 8 ; 30 frames/sec. drop-frame longInt format
- midiFormat30fpsQF EQU 9 ; 30 frames/sec. longInt format
-
- midiInternalSync EQU 0 ; internally synced
- midiExternalSync EQU 1 ; externally synced
-
-
- ; Port types
-
- midiPortTypeTime EQU 0 ; time port
- midiPortTypeInput EQU 1 ; input port
- midiPortTypeOutput EQU 2 ; output port
- midiPortTypeTimeInv EQU 3 ; invisible time port
- midiPortInvisible EQU $8000 ; invisible port, add this to the above types.
- midiPortTypeMask EQU $0007 ; AND with this to convert new port types to old,
- ; ie. to mask off the property bits.
- ; OffsetTimes
-
- midiGetEverything EQU $7FFFFFFF ; get all packets, regardless of time stamps
- midiGetNothing EQU $80000000 ; get no packets, regardless of time stamps
- midiGetCurrent EQU $00000000 ; get current packets only
-
-
-
- ;;;
- ;;; MIDI data and messages are passed in MIDIPacket records (see below).
- ;;; The first byte of every MIDIPacket contains a set of flags
- ;;;
- ;;; bits 0-1 00 = new MIDIPacket, not continued
- ;;; 01 = begining of continued MIDIPacket
- ;;; 10 = end of continued MIDIPacket
- ;;; 11 = continuation
- ;;; bits 2-3 reserved
- ;;;
- ;;; bits 4-6 000 = MIDIPacket contains MIDI data
- ;;; 001 = MIDIPacket contains MIDI Manager message
- ;;;
- ;;; bit 7 0 = MIDIPacket has valid stamp
- ;;; 1 = stamp with current clock
- ;;;
-
- midiContMask EQU $03
- midiNoCont EQU $00
- midiStartCont EQU $01
- midiMidCont EQU $03
- midiEndCont EQU $02
-
- midiTypeMask EQU $70
- midiMsgType EQU $00
- midiMgrType EQU $10
-
- midiTimeStampMask EQU $80
- midiTimeStampCurrent EQU $80
- midiTimeStampValid EQU $00
-
-
- ; MIDI Manager MIDIPacket command words (the first word in the data field
- ; for midiMgrType messages)
-
- midiOverflowErr EQU $0001
- midiSCCErr EQU $0002
- midiPacketErr EQU $0003
- midiMaxErr EQU $00FF ; all command words less than this value
- ; are error indicators
-
- ;;; ________________________________________________________________________________
- ;;;
- ;;; valid results to be returned from readHooks
- ;;;
-
- midiKeepPacket EQU 0
- midiMorePacket EQU 1
- midiNoMorePacket EQU 2
- midiHoldPacket EQU 3
-
-
- ;;; ________________________________________________________________________________
- ;;;
- ;;; Errors:
- ;;;
-
- midiNoClientErr EQU -250 ; no client with that ID found
- midiNoPortErr EQU -251 ; no port with that ID found
- midiTooManyPortsErr EQU -252 ; too many ports already installed in the system
- midiTooManyConsErr EQU -253 ; too many connections made
- midiVConnectErr EQU -254 ; pending virtual connection created
- midiVConnectMade EQU -255 ; pending virtual connection resolved
- midiVConnectRmvd EQU -256 ; pending virtual connection removed
- midiNoConErr EQU -257 ; no connection exists between specified ports
- midiWriteErr EQU -258 ; MIDIWritePacket couldn't write to all connected ports
- midiNameLenErr EQU -259 ; name supplied is longer than 31 characters
- midiDupIDErr EQU -260 ; duplicate client ID
- midiInvalidCmdErr EQU -261 ; command not supported for port type
-
-
- ;;; _________________________________________________________________________________
- ;;;
- ;;; Driver calls:
- ;;;
-
- midiOpenDriver EQU 1
- midiCloseDriver EQU 2
-
-
-
- ;;; ________________________________________________________________________________
- ;;;
- ;;; MIDI data and other messages are read and written in packets:
- ;;;
-
- MIDIPacket RECORD 0
- flags DS.B 1
- len DS.B 1
- tStamp DS.L 1
- data EQU *
- ENDR
-
-
- ;;; ________________________________________________________________________________
- ;;;
- ;;; port information
- ;;;
-
- MIDIIDRec RECORD 0
- clientID DS.L 1
- portID DS.L 1
- ENDR
-
- MIDIPortInfo RECORD 0
- type DS.W 1 ; type of port
- timeBase DS.L 2 ; MIDIIDRec for time base
- numConnects DS.W 1 ; number of connections
- cList EQU * ; ARRAY [1..numConnects] of MIDIIDRec
- ENDR
-
- MIDIPortParams RECORD 0
- portID DS.L 1 ; ID of port, unique within client
- portType DS.W 1 ; Type of port - input, output, time, etc.
- timeBase DS.W 1 ; refnum of time base, 0 if none
- offsetTime DS.L 1 ; offset for current time stamps
- readHook DS.L 1 ; routine to call when input data is valid
- refCon DS.L 1 ; refcon for port (for client use)
- sync DS.W 1 ; internal, external,other
- curTime DS.L 1 ; current local time for the port
- format DS.W 1 ; time code format in use
- name DS.B 256 ; name of the port. This is a real live string, not a ptr.
-
- size EQU * ; size of port params
- ENDR
-
-
- ;;; ________________________________________________________________________________
- ;;;
- ;;; Clocks:
- ;;;
-
- MIDIClkInfo RECORD 0
- sync DS.W 1 ; 0 = internal, 1 = external
- curTime DS.L 1 ; current value of port's clock
- format DS.W 1 ; time code format
- size EQU * ; size of MIDIClkInfo
- ENDR
-
- ;;; ________________________________________________________________________________
- ;;;
- ;;; Equates for MDVR structures
- ;;;
-
- MDVRInCtlRec RECORD 0
- timeCodeClock DS.W 1 ; refnum of time base for time code
- timeCodeFormat DS.W 1 ; format of time code output
- readProc DS.L 1 ; proc to call with intput characters
- commProc DS.L 1 ; proc to call for handshaking
- refCon DS.L 1 ; refCon passed to readProc, commProc
- ENDR
-
-
- MDVROutCtlRec RECORD 0
- timeCodeClock DS.W 1 ; time base driven by time code
- timeCodeFormat DS.W 1 ; format of time code to listen to
- timeCodeProc DS.L 1 ; proc called on time code fmt change
- commProc DS.L 1 ; proc called for handshaking
- refCon DS.L 1 ; refCon passed to timeCodeProc
- timeCodeFilter DS.W 1 ; filter time code if true
- midiMsgTicks DS.L 1 ; value of Ticks when MIDI msg rcvd
- timeCodeTicks DS.L 1 ; value of Ticks when time code rcvd
- ENDR
-
- mdvrAbortNotesOff EQU 0 ; abort previous mdvrNotesOff request
- mdvrChanNotesOff EQU 1 ; generate channel note off messages
- mdvrAllNotesOff EQU 2 ; generate all note off messages
-
- mdvrStopOut EQU 0 ; stop calling MDVROut temporarily
- mdvrStartOut EQU 1 ; resume calling MDVROut
-
- ;;; ________________________________________________________________________________
- ;;;
- ;;; Equates for function selectors
- ;;;
-
- midiVersion EQU 0
- midiSignIn EQU 4
- midiSignOut EQU 8
- midiGetClients EQU 12
- midiGetClientName EQU 16
- midiSetClientName EQU 20
- midiGetPorts EQU 24
- midiAddPort EQU 28
- midiGetPortInfo EQU 32
- midiConnectData EQU 36
- midiUnConnectData EQU 40
- midiConnectTime EQU 44
- midiUnConnectTime EQU 48
- midiFlush EQU 52
- midiGetReadHook EQU 56
- midiSetReadHook EQU 60
- midiGetPortName EQU 64
- midiSetPortName EQU 68
- midiWakeUp EQU 72
- midiRemovePort EQU 76
- midiGetSync EQU 80
- midiSetSync EQU 84
- midiGetCurTime EQU 88
- midiSetCurTime EQU 92
- midiStartTime EQU 96
- midiStopTime EQU 100
- midiPoll EQU 104
- midiWritePacket EQU 108
- midiWorldChanged EQU 112
- midiGetOffsetTime EQU 116
- midiSetOffsetTime EQU 120
- midiConvertTime EQU 124
- midiGetRefCon EQU 128
- midiSetRefCon EQU 132
- midiGetClRefCon EQU 136
- midiSetClRefCon EQU 140
- midiGetTCFormat EQU 144
- midiSetTCFormat EQU 148
- midiSetRunRate EQU 152
- midiGetClientIcon EQU 156
- midiCallAddress EQU 164
- midiSetConnectionProc EQU 168
- midiGetConnectionProc EQU 172
- midiDiscardPacket EQU 176
- MDVRSignIn EQU 180
- MDVRSignOut EQU 184
- MDVROpen EQU 188
- MDVRClose EQU 192
- MDVRControlIn EQU 196
- MDVRControlOut EQU 200
- MDVRIn EQU 204
- MDVROut EQU 208
- MDVRNotesOff EQU 212
-
- ;;; ________________________________________________________________________________
- ;;;
- ;;; Call Macros for Assembly
- ;;;
-
- ;;
- ;; Sound Dispatch trap (if not already defined)
- ;;
- IF &TYPE('_SoundDispatch') = 'UNDEFINED' THEN
- _SoundDispatch OPWORD $A800
- ENDIF
-
- ;;
- ;; fake _SndDispVersion which calls glue to make sure that the sound
- ;; dispatcher has been installed
- ;;
- MACRO
- &label _SndDispVersion
- IMPORT SndDispVersion
- &label JSR SndDispVersion ; call the sound dispatcher glue in MIDIGlue.o
- ENDM
-
-
- MACRO
- &label _CallMIDIMgr &selector
- &label MOVE.L #(&selector<<16)+midiToolNum,D0
- _SoundDispatch
- ENDM
-
-
- MACRO
- &label _MIDISignIn
- &label _CallMIDIMgr midiSignIn
- MEND
-
- MACRO
- &label _MIDISignOut
- &label _CallMIDIMgr midiSignOut
- MEND
-
- MACRO
- &label _MIDIVersion
- &label _CallMIDIMgr midiVersion
- MEND
-
- MACRO
- &label _MIDIGetClients
- &label _CallMIDIMgr midiGetClients
- MEND
-
- MACRO
- &label _MIDIGetClientName
- &label _CallMIDIMgr midiGetClientName
- MEND
-
- MACRO
- &label _MIDISetClientName
- &label _CallMIDIMgr midiSetClientName
- MEND
-
- MACRO
- &label _MMGetClientIcon
- &label _CallMIDIMgr nGetClientIcon
- MEND
-
- MACRO
- &label _MIDIGetPorts
- &label _CallMIDIMgr midiGetPorts
- MEND
-
- MACRO
- &label _MIDIAddPort
- &label _CallMIDIMgr midiAddPort
- MEND
-
- MACRO
- &label _MIDIGetPortInfo
- &label _CallMIDIMgr midiGetPortInfo
- MEND
-
- MACRO
- &label _MIDIConnectData
- &label _CallMIDIMgr midiConnectData
- MEND
-
- MACRO
- &label _MIDIUnConnectData
- &label _CallMIDIMgr midiUnConnectData
- MEND
-
- MACRO
- &label _MIDIConnectTime
- &label _CallMIDIMgr midiConnectTime
- MEND
-
- MACRO
- &label _MIDIUnConnectTime
- &label _CallMIDIMgr midiUnConnectTime
- MEND
-
- MACRO
- &label _MIDIFlush
- &label _CallMIDIMgr midiFlush
- MEND
-
- MACRO
- &label _MIDIGetReadHook
- &label _CallMIDIMgr midiGetReadHook
- MEND
-
- MACRO
- &label _MIDISetReadHook
- &label _CallMIDIMgr midiSetReadHook
- MEND
-
- MACRO
- &label _MIDIGetPortName
- &label _CallMIDIMgr midiGetPortName
- MEND
-
- MACRO
- &label _MIDISetPortName
- &label _CallMIDIMgr midiSetPortName
- MEND
-
- MACRO
- &label _MIDIWakeUp
- &label _CallMIDIMgr midiWakeUp
- MEND
-
- MACRO
- &label _MIDIRemovePort
- &label _CallMIDIMgr midiRemovePort
- MEND
-
- MACRO
- &label _MIDIGetSync
- &label _CallMIDIMgr midiGetSync
- MEND
-
- MACRO
- &label _MIDISetSync
- &label _CallMIDIMgr midiSetSync
- MEND
-
- MACRO
- &label _MIDIGetCurTime
- &label _CallMIDIMgr midiGetCurTime
- MEND
-
- MACRO
- &label _MIDISetCurTime
- &label _CallMIDIMgr midiSetCurTime
- MEND
-
- MACRO
- &label _MIDIStartTime
- &label _CallMIDIMgr midiStartTime
- MEND
-
- MACRO
- &label _MIDIStopTime
- &label _CallMIDIMgr midiStopTime
- MEND
-
- MACRO
- &label _MIDIPoll
- &label _CallMIDIMgr midiPoll
- MEND
-
- MACRO
- &label _MIDIWritePacket
- &label _CallMIDIMgr midiWritePacket
- MEND
-
- MACRO
- &label _MIDIWorldChanged
- &label _CallMIDIMgr midiWorldChanged
- MEND
-
- MACRO
- &label _MIDIGetOffsetTime
- &label _CallMIDIMgr midiGetOffsetTime
- MEND
-
- MACRO
- &label _MIDISetOffsetTime
- &label _CallMIDIMgr midiSetOffsetTime
- MEND
-
- MACRO
- &label _MIDIConvertTime
- &label _CallMIDIMgr midiConvertTime
- MEND
-
- MACRO
- &label _MIDIGetRefCon
- &label _CallMIDIMgr midiGetRefCon
- MEND
-
- MACRO
- &label _MIDISetRefCon
- &label _CallMIDIMgr midiSetRefCon
- MEND
-
- MACRO
- &label _MIDIGetClRefCon
- &label _CallMIDIMgr midiGetClRefCon
- MEND
-
- MACRO
- &label _MIDISetClRefCon
- &label _CallMIDIMgr midiSetClRefCon
- MEND
-
- MACRO
- &label _MIDIGetTCFormat
- &label _CallMIDIMgr midiGetTCFormat
- MEND
-
- MACRO
- &label _MIDISetTCFormat
- &label _CallMIDIMgr midiSetTCFormat
- MEND
-
- MACRO
- &label _MIDISetRunRate
- &label _CallMIDIMgr midiSetRunRate
- MEND
-
- MACRO
- &label _MIDIGetClientIcon
- &label _CallMIDIMgr midiGetClientIcon
- MEND
-
-
- MACRO
- &label _MIDICallAddress
- &label _CallMIDIMgr midiCallAddress
- MEND
-
- MACRO
- &label _MIDISetConnectionProc
- &label _CallMIDIMgr midiSetConnectionProc
- MEND
-
- MACRO
- &label _MIDIGetConnectionProc
- &label _CallMIDIMgr midiGetConnectionProc
- MEND
-
- MACRO
- &label _MIDIDiscardPacket
- &label _CallMIDIMgr midiDiscardPacket
- MEND
-
- MACRO
- &label _MDVRSignIn
- &label _CallMIDIMgr MDVRSignIn
- MEND
-
- MACRO
- &label _MDVRSignOut
- &label _CallMIDIMgr MDVRSignOut
- MEND
-
- MACRO
- &label _MDVROpen
- &label _CallMIDIMgr MDVROpen
- MEND
-
- MACRO
- &label _MDVRClose
- &label _CallMIDIMgr MDVRClose
- MEND
-
- MACRO
- &label _MDVRControlIn
- &label _CallMIDIMgr MDVRControlIn
- MEND
-
- MACRO
- &label _MDVRControlOut
- &label _CallMIDIMgr MDVRControlOut
- MEND
-
- MACRO
- &label _MDVRIn
- &label _CallMIDIMgr MDVRIn
- MEND
-
- MACRO
- &label _MDVROut
- &label _CallMIDIMgr MDVROut
- MEND
-
- MACRO
- &label _MDVRNotesOff
- &label _CallMIDIMgr MDVRNotesOff
- MEND
-
-